﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace classMeeting.App_Code
{

    public class CheckLogin
    {
        private String name;
        private String schoolId;
        public CheckLogin(String name, String schoolId)
        {
            this.name = name;
            this.schoolId = schoolId;
        }

        public bool isStudent()
        {
            DataSet dt = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM classMeeting.dbo.admin WHERE schoolID ='" + schoolId + "' AND userType='student'");
            if (dt.Tables[0].Rows.Count <= 0)
                return false;
            else
                return true;
        }

        public bool isClassInstructor()
        {
            DataSet dt = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM classMeeting.dbo.admin WHERE schoolID ='" + schoolId + "' AND userType='classInstructor'");
            if (dt.Tables[0].Rows.Count <= 0)
                return false;
            else
                return true;
        }

        public bool isCollegeInstructor()
        {
            DataSet dt = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM classMeeting.dbo.admin WHERE schoolID ='" + schoolId + "' AND userType='collegeInstructor'");
            if (dt.Tables[0].Rows.Count <= 0)
                return false;
            else
                return true;
        }

        public bool isAdmin()
        {
            DataSet dt = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM classMeeting.dbo.admin WHERE schoolID ='" + schoolId + "' AND userType='administrator'");
            if (dt.Tables[0].Rows.Count <= 0)
                return false;
            else
                return true;
        }
    }
}